#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
创建代码提取器图标
"""

import os
try:
    from PIL import Image, ImageDraw, ImageFont
except ImportError:
    print("正在安装Pillow库...")
    import subprocess
    import sys
    subprocess.check_call([sys.executable, "-m", "pip", "install", "Pillow"])
    from PIL import Image, ImageDraw, ImageFont

def create_icon():
    """创建一个简单的图标"""
    # 创建一个256x256的图像，带透明背景
    img = Image.new('RGBA', (256, 256), color=(0, 0, 0, 0))
    draw = ImageDraw.Draw(img)
    
    # 绘制一个圆形背景
    draw.ellipse((20, 20, 236, 236), fill=(65, 105, 225, 255))  # 蓝色背景
    
    # 绘制一个代码符号
    try:
        # 尝试加载字体
        font = ImageFont.truetype("arial.ttf", 120)
    except IOError:
        # 如果找不到字体，使用默认字体
        font = ImageFont.load_default()
    
    # 绘制文本
    draw.text((70, 60), "</>", fill=(255, 255, 255, 255), font=font)
    
    # 保存为PNG
    img.save("icon.png")
    
    # 转换为ICO
    img.save("icon.ico", format="ICO", sizes=[(256, 256), (128, 128), (64, 64), (32, 32), (16, 16)])
    
    print("图标已创建: icon.ico")

if __name__ == "__main__":
    create_icon() 